<!DOCTYPE HTML><html>
<head>
<? echo $h->meta($title, $kwd, $dpn); ?>
<? require_once("lib.php"); ?>
</head>

<body>
<? include_once("header.php"); ?>
<div id="wrap">
	<div id="main">
		<ul class="flow_step">
			<li class="step1"><?=WEB_MY_CART?></li>
			<li><?=WEB_FILL_CHECK_ORDER?></li>
			<li><?=WEB_SUCCESS_SUBMIT_ORDER?></li>
		</ul><!--end flow_step-->
		<div class="clear"></div>
		<? if($cart_qty==0){ ?>
		<div class="emptycart"><a href="./" class="block"><span>&nbsp;</span><?=WEB_CART_IS_EMPTY?></a></div>
		<? } else { ?>
		<table class="table_cart" cellpadding="0" cellspacing="0">
			<thead>
				<tr>
					<th width="380"> &nbsp; <?=WEB_ITEM_IN_CART?></th>
					<th><?=WEB_UNIT_PRICE?></th>
					<th><?=WEB_PURCHASE_QUANTITY?></th>
					<th><?=WEB_STOCK?></th>
					<th><?=WEB_SUBTOTAL?></th>
					<th class="act"><?=WEB_OPERATION?></th>
				</tr>
			</thead>
			<tbody>
				<?
					$str='';
					$total=0;
					foreach($cart as $row){
						$tem_product=$product->get_row($row['pid']);
						$tem_price=price($tem_product);
						$tem_old_price=discount($tem_product);
						$tem_stock=$tem_product['stock'];

						$tem_pic=$tem_product['small_pic'];
						$tem_link=seo_url($tem_product['name_'.$lang]).'-p-'.$row['pid'].'.html';
						$tem_name=str_cut($tem_product['name_'.$lang],PRODUCT_TITLE_DISPLAY_LENGTH,$lang);
						$tem_qty=$row['qty'];


						// variation
						$str_var='';
						if($row['var']){
							$tem_var=$product_variation->get_row($row['var']);
							//$tem_price=round($tem_var['price']*$currency_rate,2); // var
							$tem_price=price($tem_var,1);
							$tem_old_price=discount($tem_var,1);
							$tem_stock=$tem_var['stock'];  // var
							if($tem_var['size']) $str_var.=$option_label[2].': '.$option_value[$tem_var['size']].' &nbsp; ';
							if($tem_var['color']) $str_var.=$option_label[1].': '.$option_value[$tem_var['color']].' &nbsp; ';
							if($tem_var['other1']) $str_var.=$option_label[3].': '.$option_value[$tem_var['other1']].' &nbsp; ';
							if($tem_var['other2']) $str_var.=$option_label[4].': '.$option_value[$tem_var['other2']].' &nbsp; ';
						}

						$has_stock=$tem_stock>=$tem_qty?1:0;
						if($has_stock) $can_buy=1;
						$tem_stock_tip=$has_stock?WEB_WITH_STOCK:'<span class="red">'.WEB_NO_STOCK.'</span>';

						if($has_stock){
							$tem_total=$tem_qty*$tem_price;
							$total+=$tem_total;
						$str.='<tr>
					<td class="tl"><div class="goods"><span class="image"><a href="'.$tem_link.'" target="_blank"><img src="'.PRODUCT_PIC_HOST.$tem_pic.'"/></a></span><div class="name"><a href="'.$tem_link.'" target="_blank">'.$tem_name.'</a><br /><br /><span class="gray">'.$str_var.'</span></div><div class="clear"></div></div></td>
					<td><strong class="price">'.$currency_sign.' '.$tem_price.$tem_old_price.'</strong></td>
					<td><div class="wrap-input">
						<a class="btn-reduce" onclick="cart_qty_reduce('.$row['pid'].','.$row['var'].','.$row['qty'].')">'.WEB_QUANTITY_LESS.'</a>
						<a class="btn-add" onclick="cart_qty_add('.$row['pid'].','.$row['var'].','.$row['qty'].','.$tem_stock.')">'.WEB_QUANTITY_ADD.'</a>
						<input class="text" id="" value="'.$tem_qty.'" onkeyup="cart_qty_update('.$row['pid'].','.$row['var'].',$(this).val(),'.$tem_stock.');"/>
					</div></td>
					<td>'.$tem_stock_tip.'</td>
					<td><strong class="price red">'.$currency_sign.' '.$tem_total.'</strong></td>
					<td class="todo_link tr act" onclick="cart_remove('.$row['pid'].','.$row['var'].')"><a>'.WEB_DELETE.'</a></td>
				</tr>';
					}
						else {
						$str.='<tr>
					<td class="tl"><div class="goods"><span class="image"><a href="'.$tem_link.'" target="_blank"><img src="upload/'.$tem_pic.'"/></a></span><div class="name"><a href="'.$tem_link.'" target="_blank">'.$tem_name.'</a><br /><br /><span class="gray">'.$str_var.'</span></div><div class="clear"></div></div></td>
					<td><strong class="price">'.$currency_sign.' '.$tem_price.'</strong></td>
					<td><div class="wrap-input">
						<a class="btn-reduce" onclick="cart_qty_reduce('.$row['pid'].','.$row['var'].','.$row['qty'].')">'.WEB_QUANTITY_LESS.'</a>
						<a class="btn-add" onclick="cart_qty_add('.$row['pid'].','.$row['var'].','.$row['qty'].','.$tem_stock.')">'.WEB_QUANTITY_ADD.'</a>
						<input class="text" id="" value="'.$tem_qty.'" onkeyup="cart_qty_update('.$row['pid'].','.$row['var'].',$(this).val(),'.$tem_stock.');"/>
					</div></td>
					<td>'.$tem_stock_tip.'</td>
					<td><strong class="price red">-</strong></td>
					<td class="todo_link tr act" onclick="cart_remove('.$row['pid'].','.$row['var'].')"><a>'.WEB_DELETE.'</a></td>
				</tr>';
					}
				}
					echo $str;
				?>
			</tbody>
			<tfoot>
				<tr>
					<th colspan="6">
						<div class="checkleft"><a onclick="cart_clear();"><?=WEB_EMPTY_CART?></a></div>
						<div class="price_check_box">
							
							<div class="price_list">
								<div class="total">
									<p class="hide"><span class="t"><?=WEB_TOTAL_FOR_ITEMS?>: </span><span class="txt price"><? echo $currency_sign.' '.$total ?></span></p>
									<p class="hide"><span class="t"><?=WEB_DISCOUNT_AMOUNT?>: </span><span class="txt price"><? echo $currency_sign ?> 0.00</span></p>
									<p><span class="t all"><?=WEB_TOTAL_FOR_ITEMS?>：</span> <span class="txt finalprice"><? echo $currency_sign.' '.$total ?></span></p>
								</div>
								<div class="cart_buttom">
									<a class="continue" href="./"><?=WEB_CONTINUE_SHOPPING?></a>
									<? if($can_buy){ ?><a class="payment" href="order.html"><?=WEB_TO_CHECKOUT?></a><? } ?>
								</div>
							</div>
							<div class="clear"></div>
						</div><div class="clear"></div>
					</th>
				</tr>
			</tfoot>
		</table>
		<? } // 判断购物车是否为空结束 ?>
	<?
	// hot items 热销产品
	if(count($arr_hot)>0){
	?>
	<div class="px20"></div><div class="px20"></div>
	<div id="hot">
		<div class="h2index"><h2 class="left"><a><?=WEB_HOT_ITEMS?></a></h2><div class="more right gray"><a href="category.html"><?=WEB_VIEW_MORE?>>></a></div><div class="clear"></div></div>
		<div class="hot">
			<ul class="hlist_fs">
				<?
						$str='';
						foreach ($arr_hot as $key => $val) {
							$tem_link=seo_url($val['name_'.$lang]).'-p-'.$val['id'].'.html';
							$tem_pic=PRODUCT_PIC_HOST.$val['small_pic'];
							$tem_name=str_cut($val['name_'.$lang],PRODUCT_TITLE_DISPLAY_LENGTH,$lang);
							//$tem_price=round($val['price']*$currency_rate,2);
							$tem_price=price($val).discount($val);
							$str.='<li class="hlist_li">
						<div class="hlist_f">
							<div class="hlist_pro">
								<div class="image"><a href="'.$tem_link.'"><img src="'.$tem_pic.'" width="'.PRODUCT_SMALL_PIC_WIDTH.'" height="'.PRODUCT_SMALL_PIC_HEIGHT.'" /></a></div>
								<div class="pname"><a href="'.$tem_link.'">'.$tem_name.'</a></div>
								<div class="price"><span><span>'.$currency_sign.'</span>'.$tem_price.'</span></div>
							</div>
						</div>
					</li>';
						}
						echo $str;
					?>
			</ul>
			<div class="clear"></div>
		</div>
	</div><!--# hot-->
	<? } // hot items end ?>
	</div><!--main end-->
</div><!--wrap end-->
<? include("footer.php"); ?>
</body>
</html>